<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .container {
            width: 300px;
            margin: 100px auto;
        }
        
        .box {
            width: 100px;
            height: 100px;
            background-color: rgb(97, 56, 56);
        }
        
        .wh {
            width: 200px;
        }
        
        .hei {
            height: 200px;
        }
        
        .co {
            background-color: rgb(63, 116, 47);
        }
        
        .hi {
            visibility: hidden;
        }
    </style>
</head>

<body>
    <div class="container">
        <button class="btn">变宽</button>
        <button class="btn">变高</button>
        <button class="btn">变颜色</button>
        <button class="btn">隐藏</button>
        <button class="btn">重置</button>
        <div class="box"></div>
    </div>
    <script>
        var btns = document.querySelectorAll('.btn');
        var box = document.querySelector('.box')
        btns[0].onclick = function() {
            box.classList.toggle('wh')
        }
        btns[1].onclick = function() {
            box.classList.toggle('hei')
        }
        btns[2].onclick = function() {
            box.classList.toggle('co')
        }
        btns[3].onclick = function() {
            box.classList.toggle('hi')
        }
        btns[4].onclick = function() {
            // var cl = ['wh', 'hei', 'co', 'hi']
            // cl.forEach(function(el) {
            //     box.classList.remove(el)
            // })
            box.className = "box"
        }
    </script>
</body>

</html>